﻿Ext.namespace('FantastPlatform', 'FantastPlatform.UI');
FantastPlatform.UI.PersonTaskGrid = function (config) {
    Ext.apply(this, config);
    var fileStore = new Ext.data.Store({
        proxy: new Ext.data.HttpProxy({
            url: '../Service/PersonTaskService.aspx?Action=GetPersonByTaskId?Id=' + this.taskId
        }),
        reader: new Ext.data.JsonReader({
            root: 'topics',
            totalProperty: 'totalCount',
            id: 'Id',
            fields: ['Id', 'Name', 'Code']
        }),
        remoteStore: true
    });

    this.store = fileStore;
    var paperBar = new FantastPlatform.Common.PapeToolBar({
        store: fileStore,
        defaultNum: 21
    });
    this.paperBar = paperBar;
    this.bbar = paperBar;
    this.pageNumber = paperBar.pageSize;


    var nm = new Ext.grid.RowNumberer();
    var sm = new Ext.grid.CheckboxSelectionModel();

    this.columns = [nm, sm, {
        header: 'Id',
        dataIndex: 'Id',
        hidden: true
    }, {
        header: '名称',
        dataIndex: 'Name',
        sortable: true
    }, {
        header: '警号',
        dataIndex: 'Code',
        sortable: true
    }]

    FantastPlatform.UI.PersonTaskGrid.superclass.constructor.call(this, {
        loadMask: { msg: '正在加载数据...' },
        sm: sm
    });
};
Ext.extend(FantastPlatform.UI.PersonTaskGrid, Ext.grid.GridPanel, {
    onRender: function (ct, position) {
        FantastPlatform.UI.PersonTaskGrid.superclass.onRender.call(this, ct, position);
    },

    onUpdataGrid: function () {
        this.store.removeAll();
        this.store.load({ params: { start: 0, limit: this.paperBar.getPageNumber(), dir: '', sort: ''} });
    }
});